<style lang="scss" scoped>
/* 页脚样式优化 */
.v-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* 导航栏样式 */
.custom-app-bar {
  backdrop-filter: blur(20px);
  background: linear-gradient(135deg, #00acc1 0%, #00e676 100%) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideDown 0.6s ease-out;
}

.custom-app-bar.scrolled {
  background: rgba(102, 126, 234, 0.95) !important;
  backdrop-filter: blur(25px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: scale(1.1);
}

/* 移动端抽屉样式 */
.mobile-drawer {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  backdrop-filter: blur(20px);
}

.mobile-menu-item {
  color: white !important;
  font-weight: 500;
  margin-bottom: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.mobile-menu-item:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: translateX(8px);
}

/* 响应式设计 */
@media (max-width: 960px) {
  .nav-menu {
    display: none;
  }

  .logo-section {
    flex: 1;
  }

  .logo-text {
    font-size: 1.25rem;
  }

  .version-chip {
    display: none;
  }
}
/* Logo 区域样式 */
.logo-section {
  transition: all 0.3s ease;
}

.logo-avatar {
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo-text {
  background: linear-gradient(45deg, #ffeb3b, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.version-chip {
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 导航菜单样式 */
.nav-menu {
  gap: 4px;
}

.nav-btn {
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.nav-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.nav-btn:hover::before {
  left: 100%;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-divider {
  height: 24px;
  border-color: rgba(255, 255, 255, 0.3);
}

/* 登录按钮样式 */
.login-btn {
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* 主题切换按钮样式 */
.theme-btn {
  transition: all 0.3s ease;
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: rotate(180deg);
}

@media (max-width: 600px) {
  .custom-app-bar {
    padding: 0 16px;
  }

  .logo-avatar {
    width: 32px !important;
    height: 32px !important;
  }

  .logo-text {
    font-size: 1.1rem;
  }
}

/* 导航栏动画效果 */
@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 按钮波纹效果优化 */
.nav-btn .v-ripple__container {
  color: rgba(255, 255, 255, 0.3);
}

.login-btn .v-ripple__container {
  color: rgba(102, 126, 234, 0.3);
}
</style>

<template>
  <v-layout class="flex-column overflow-y-hidden" style="height: 100vh">
    <!-- 顶部导航栏 -->
    <v-app-bar elevation="2" class="custom-app-bar px-4">
      <template v-if="!isMobile">
        <!-- Logo 和标题区域 -->
        <div class="d-flex align-center logo-section">
          <v-avatar size="40" class="me-3 logo-avatar">
            <v-img :src="logoSrc" alt="轻云blog"></v-img>
          </v-avatar>
          <v-toolbar-title class="text-h5 font-weight-bold logo-text"> 轻云blog </v-toolbar-title>
          <!-- <v-chip size="small" color="white" variant="tonal" class="ms-3 version-chip"> v2.0 </v-chip> -->
        </div>

        <v-spacer></v-spacer>

        <!-- 导航菜单 -->
        <div class="d-flex align-center nav-menu">
          <v-btn
            @click="toPage('/')"
            class="mx-1 nav-btn"
            text="首页"
            variant="text"
            color="white"
            prepend-icon="mdi-home"
            rounded="lg"
          ></v-btn>
          <v-btn
            @click="toPage('/blog-classify')"
            class="mx-1 nav-btn"
            text="归档"
            variant="text"
            color="white"
            prepend-icon="mdi-folder-multiple"
            rounded="lg"
          ></v-btn>
          <v-btn
            class="mx-1 nav-btn"
            text="项目资源"
            variant="text"
            color="white"
            prepend-icon="mdi-folder-star"
            rounded="lg"
          ></v-btn>
          <v-btn
            @click="toPage('/leave-message')"
            class="mx-1 nav-btn"
            text="留言"
            variant="text"
            color="white"
            prepend-icon="mdi-message-text"
            rounded="lg"
          ></v-btn>

          <!-- 分隔线 -->
          <v-divider vertical class="mx-3 nav-divider"></v-divider>

          <!-- 登录按钮 -->
          <v-btn
            @click="toPage('/login')"
            class="mx-1 login-btn"
            color="white"
            variant="elevated"
            prepend-icon="mdi-account"
            rounded="lg"
          >
            登录/注册
          </v-btn>

          <!-- 主题切换按钮 -->
          <v-btn
            class="mx-1 theme-btn"
            icon="mdi-theme-light-dark"
            variant="text"
            color="white"
            rounded="lg"
          ></v-btn>
        </div>
      </template>

      <!-- 移动端菜单按钮 -->
      <v-btn
        v-else
        class="d-md-none mobile-menu-btn"
        icon="mdi-menu"
        variant="text"
        color="white"
        @click="mobileMenuOpen = !mobileMenuOpen"
      ></v-btn>
    </v-app-bar>

    <!-- 移动端菜单抽屉 -->
    <v-navigation-drawer
      v-if="isMobile"
      v-model="mobileMenuOpen"
      temporary
      location="top"
      class="mobile-drawer"
    >
      <v-list class="pa-4">
        <v-list-item
          v-for="item in mobileMenuItems"
          :key="item.title"
          :prepend-icon="item.icon"
          :title="item.title"
          class="mobile-menu-item"
          @click="toPage(item.path)"
        ></v-list-item>
      </v-list>
    </v-navigation-drawer>
    <router-view></router-view>
    <!-- 页脚 -->
    <v-footer class="text-center d-flex flex-column ga-2 py-4" color="grey-lighten-4">
      <div class="d-flex ga-3">
        <v-btn
          v-for="icon in icons"
          :key="icon"
          :icon="icon"
          density="comfortable"
          variant="text"
          color="grey-darken-1"
        ></v-btn>
      </div>

      <v-divider class="my-2" thickness="2" width="50" color="grey"></v-divider>

      <div class="text-caption font-weight-regular text-grey-darken-1">
        轻云blog - 分享技术，记录生活，追求卓越
      </div>

      <v-divider color="grey"></v-divider>

      <div class="text-caption text-grey-darken-1">
        {{ new Date().getFullYear() }} — <strong>轻云blog</strong>
      </div>
    </v-footer>
  </v-layout>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import logoSrc from '@/assets/img/logo.png'
import { useDisplay } from 'vuetify'
const icons = ['mdi-facebook', 'mdi-twitter', 'mdi-linkedin', 'mdi-instagram']
const router = useRouter()

const toPage = function (path) {
  if (path === router.currentRoute.value.path) return
  mobileMenuOpen.value = false
  router.push(path)
}

const mobileMenuOpen = ref(false)
const isMobile = useDisplay().smAndDown
// 区分移动端的代码

// 移动端菜单项
const mobileMenuItems = ref([
  { title: '首页', icon: 'mdi-home', path: '/' },
  { title: '分类归档', icon: 'mdi-folder-multiple', path: '/blog-classify' },
  { title: '项目资源', icon: 'mdi-folder-star', path: '/project-resource' },
  { title: '留言', icon: 'mdi-message-text', path: '/leave-message' },
  { title: '登录/注册', icon: 'mdi-account', path: '/login' }
  // { title: '关于我', icon: 'mdi-account', path: '/about' }
])
</script>
